<style lang="scss" scoped>
</style>
<template>
  <div class="set_wx_zfb baseW">
    <!-- 顶部导航 -->
    <van-nav-bar
      title="绑定支付"
      right-text="保存"
      left-arrow
      @click-left="$router.go(-1)"
      @click-right="onClickRight"
    />
    <van-cell-group>
      <van-field
        class="wx"
        v-model="wx"
        input-align="right"
        colon
        center
        clickable
        autofocus
        label-width="100px"
        label="微信账号"
        placeholder="请输入微信账号"
      />
      <van-field
        class="zfb"
        v-model="zfb"
        input-align="right"
        colon
        center
        clickable
        autofocus
        label-width="100px"
        label="支付宝账号"
        placeholder="请输入支付宝账号"
      />
    </van-cell-group>
  </div>
</template>

<script>
import {updateWXAndZFB} from '../../api/user'
import { Toast } from "vant";
export default {
  data: () => ({
    wx: "",
    zfb: "",
  }),
  created(){
    this.wx = this.$store.state.userInfo.pay_type.wx;
    this.zfb = this.$store.state.userInfo.pay_type.zfb;
  },
  methods: {
    async onClickRight() {
      let { wx, zfb } = this;
      let return_msg = await updateWXAndZFB({wx,zfb});
      console.log(return_msg);
      this.$store.commit("setUserPayTypeWX", wx);
      this.$store.commit("setUserPayTypeZFB", zfb);
      Toast.success("修改成功!");
      setTimeout(() => {
        this.$router.go(-1);
      }, 500);
      // if (wx && zfb) {
      // } else {
      //   Toast.fail("填写后再保存");
      // }
    },
  },
};
</script>